home *** CD-ROM | disk | FTP | other *** search
Text File | 1989-07-18 | 3.4 KB | 115 lines | [TEXT/GEOL] |
- Item 0791527 17-July-89 10:24
-
- From: D3904 The Complete PC, PRT
-
- To: MACDTS Macintosh Developer Technical Supt.
-
- cc: MACAPP.TECH$ MACAPP Tech
-
- Sub: putPicProc Abnormalities
-
- 7/17/89
-
- To: MacDTS
-
- From: Ann Huang
-
- cc: MACAPP.TECH$
-
- With MacApp 2.0b5, we are try to spool a picture to a file in a very similar
- fashion to the example in Inside Macintosh Vol. 5, pgs. 89-90. The problem is
- that the example is not very clear. In other words, we can't get it to work.
-
- The example uses DrawPicture and we want to use CopyBits to convert our
- internal scanned-in bitmap to PICT format. This seems to be causing us some
- problems. Our new putPicProc procedure never gets called with the right
- parameters. And, strangely enough the default procedure never seems to be
- called at all with CopyBits (when we do not overwrite the bottleneck).
-
- The reason we want to do this is two-fold, one, we want to know the size of
- the bitmap as a PICT for our DoNeedDiskSpace routine; and two, we want to
- write our bitmap to disk as a PICT. Currently, we are just making a
- duplicate in memory with CopyBits and then writing to disk (a rather gross
- misuse of memory).
-
- Here is our code (please flame us):
- {-----------------------------------+
- | ConvertToPICT |
- +-----------------------------------}
- FUNCTION ConvertToPICT:LONGINT;
- CONST
- DrawBegin = 130;
- DrawEnd = 131;
- BitBegin = 142;
- BitEnd = 143;
-
- VAR
- frameRect,
- pictRect: Rect;
- tempPort: GrafPort;
- aPicture: PicHandle;
- aBitMap: BitMap;
- totalCount: LONGINT;
- myProcs: QDProcs;
- savedProcs: QDProcsPtr;
-
- {----------------------------------------------------+
- | PutPICTData: find out the size of the picture |
- +----------------------------------------------------}
-
- PROCEDURE PutPICTData(dataPtr: Ptr; byteCount: INTEGER);
- VAR
- longCount : LONGINT;
- err : OSErr;
- BEGIN
- longCount := LONGINT(byteCount);
- totalCount := totalCount + longCount;
- END;
-
- BEGIN
- {create the picture}
- OpenPort(@tempPort);
- aBitMap := fScanBitMap;
- SetPortBits(aBitMap);
- fScanView.GetQDExtent(pictRect);
- SetPort(@tempPort);
- ScaleRect(pictRect,frameRect,dpi(fImageResolution),dpi(fSaveResolution));
-
- totalCount := LONGINT(0);
-
- SetStdProcs(myProcs); { re-route to our procedure }
- myProcs.putPicProc := @PutPICTData;
- savedProcs := thePort^.grafProcs;
- thePort^.grafProcs := @myProcs;
-
- aPicture := OpenPicture(frameRect);
- PicComment(DrawBegin,0,NIL);
- PicComment(BitBegin,0,NIL);
- ClipRect(pictRect);
- CopyBits(aBitMap,aBitMap,pictRect,frameRect,srcCopy,NIL);
- PicComment(BitEnd,0,NIL);
- PicComment(DrawEnd,0,NIL);
- ClosePicture;
- thePort^.grafProcs := savedProcs;
-
- ClosePort(@tempPort);
-
- {check if picture creation failed}
- IF EmptyRect(aPicture^^.picFrame) THEN
- BEGIN
- KillPicture(aPicture);
- Failure(memFullErr, 0);
- END;
- gPicture := Handle(aPicture);
- ConvertToPICT := GetHandleSize(gPicture)
- END;
-
- This question is MacApp related to the extent that we are hoping there is a
- MacApp procedure we are overlooking that will help us achieve a similar result.
-
- Thanks in advance.
-
- Ann
-
-
-